package com.cdpark.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.cdpark.service.CDService;
import com.cdpark.vo.MyShopCartCDVO;

public class InitAction extends Action {

	private CDService cdService = new CDService();
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		List newCDList  = cdService.searchAllNewCDs();
		
		List recommandCDList = cdService.searchAllRecommandCDs();
		
		List cdTypeList = cdService.searchAllCDTypes();
		
		List goodSellCDList = cdService.searchGoodSellCDs();
		
		MyShopCartCDVO myShopCartVO = new MyShopCartCDVO();
		
		
		HttpSession session = request.getSession();
		session.setAttribute("newCDList", newCDList);
		session.setAttribute("recommandCDList", recommandCDList);
		session.setAttribute("cdTypeList", cdTypeList);
		session.setAttribute("goodSellCDList", goodSellCDList);
		session.setAttribute("myShopCart", myShopCartVO);
		response.sendRedirect("main.jsp");
		
		return null;
	}

	
	
}
